//@author A0084556W
package Main;

import java.util.Vector;

public class Search{
	private Item toCheck;
	private Vector<Item> tempItemList = new Vector<Item>();
	private Vector <Item> matchingItems = new Vector <Item>();
	
	public void setItem(Item userinput){
		toCheck = userinput;
	}
	
	public void setTempItemList(Vector<Item> t){
		tempItemList = t;
	}
	
	public void doingTheSearchAlgo (){
		int numberOfItems = tempItemList.size();
		
		for (int i = 0; i < numberOfItems; i++){
			Item tempItem = tempItemList.get(i);
			
			if (toCheck.getName()!= null && !(toCheck.getName().equals (tempItem.getName())) )
				continue;
			if (toCheck.getPrice()!= 0.00 && toCheck.getPrice() != tempItem.getPrice())
				continue;
			if (toCheck.getNecessityValue() != 0 && toCheck.getNecessityValue() != tempItem.getNecessityValue())
				continue;
			if (toCheck.getDate().getDay() != 0 && !(toCheck.getDate().getDay() == tempItem.getDate().getDay()))
				continue;
			if (toCheck.getDate().getMonth() != 0 && !(toCheck.getDate().getMonth() == tempItem.getDate().getMonth()))
				continue;
			if (toCheck.getDate().getYear() != 0 && !(toCheck.getDate().getYear() == tempItem.getDate().getYear()))
				continue;
			if (toCheck.getPlace() != null && !(toCheck.getPlace().equals( tempItem.getPlace())))
				continue;
			if (toCheck.getCategory() != null && !(toCheck.getCategory().equals( tempItem.getCategory())))
				continue;
			if (toCheck.getPay() != null && !(toCheck.getPay().equals( tempItem.getPay())))
				continue;
			
			matchingItems.add(tempItem);
		}		
	}
	public Vector<Item> getMatchingItem(){
		return matchingItems;
	}
}
